﻿using System;
using System.Collections.Generic;
using System.Text;
using Volo.Abp;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;

namespace mozhi.smarterp.Business.Purchases
{
    /// <summary>
    /// 采购申请和采购订单关联关系
    /// </summary>
    public class PurchaseRequisitionOrder : AuditedAggregateRoot<Guid>, IMultiTenant
    {
        public Guid? TenantId { get; private set; }

        public Guid RequisitionId { get; private set; }

        public Guid RequisitionItemId {  get; private set; }

        public decimal RequisitionBasicQuantity { get; private set; }

        public Guid OrderId { get; private set; }

        public Guid OrderItemId {  get; private set; }

        public decimal OrderBasicQuantity {  get; private set; }


        private PurchaseRequisitionOrder() { }

        public PurchaseRequisitionOrder(Guid id, Guid requisitionId, Guid requisitionItemId , decimal requisitionBasicQuantity ,  Guid orderId , Guid orderItemId , decimal orderBasicQuantity)
        {
            Id = id;
            RequisitionId = requisitionId;
            RequisitionItemId = requisitionItemId;
            OrderId = orderId;
            OrderItemId = orderItemId;
            OrderBasicQuantity = orderBasicQuantity;
            RequisitionBasicQuantity = requisitionBasicQuantity;

            Validate();
        }

        #region
        private void Validate()
        {
            Check.NotDefaultOrNull<Guid>(RequisitionId ,nameof(RequisitionId));
            Check.NotDefaultOrNull<Guid>(RequisitionItemId, nameof(RequisitionItemId));
            Check.NotDefaultOrNull<Guid>(OrderId, nameof(OrderId));
            Check.NotDefaultOrNull<Guid>(OrderItemId, nameof(OrderItemId));

            Check.Positive(RequisitionBasicQuantity, nameof(RequisitionBasicQuantity));
            Check.Positive(OrderBasicQuantity, nameof(OrderBasicQuantity));
        }
        #endregion
    }
}
